<%-- 
    Document   : manager_login
    Created on : Feb 23, 2012, 3:52:55 PM
    Author     : Ervin  James
--%>

<%@page import="ContentManagers.RoleManagers.AuthenticationManager"%>
<%@page import="ContentManagers.Servlets.ServletManagerLogin"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>
<% //employ temporary session management here
        try{
          
                if(session.getAttribute("username") != null && (session.getAttribute("username").equals("xxxxdefaultxxxx") == false))
                {   new AuthenticationManager().redirectToProperIndex(0, request, response); 
                    
                }
                
                else{
        %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="css/managing_int.css" />
    </head>
    <body>
    <center><br><Br><br><br><br><br><br> 
    <div class="login_box" id ="managing_login">
         <img src="images/foo_man.png">
         
         <% //This section is for the simple login lockout mechanism. 

                            try{

                            ServletManagerLogin.resetIfTimeOut(request); 

                            if(session.getAttribute("formLockout").toString().equals("off"))
                                {  //login form will appear if attemptCount < 5
                                    System.out.print(session.getAttribute("formLockout"));
                                %>
         
         <br><form name ="manager_login" method="post" onsubmit="" action="../ServletManagerLogin">
         <br> Username:
         <br><input class="inputbox" id="managerUsernameField" type="text" value="" name="username" autocomplete ="off" onfocus="clearInitial(this, 'Username')" onBlur="checkManagerLogin()"/>
         <br> Password:
         <br><input class="inputbox" id="managerPasswordField" type="password" value="" name="password" autocomplete ="off" onfocus="clearInitial(this, 'Password')" onBlur="checkManagerLogin()"/>
         <br><input type="radio" name="type" value="product" checked> Product Manager
         <br><input type="radio" name="type" value="accounting"> Accounting Manager
         <br><input type="submit" id="managerSubmitLogin" name="SubmitManagerLogin" value="Login"/>
         <br>
         <%
            if(session.getAttribute("loginError")!=null)
            {
                if(session.getAttribute("loginError").equals("invalid"))
                    out.println("Invalid username and password.");
                
                session.removeAttribute("loginError");
            }
         %>
         </form>
         <% }
                        else 
                            { //display this div if attemptCount = 5

                            %>
                                <div id="login_div">
                                    <br><br><br>Login lockout for 5 minutes. <br><br><br><br>
                                </div>

                        <% } %>
         <br>
         <a href="../index.jsp"> Go Back.</a>
    </div>
    </center>
         
         
         
         
    </body>
        <%  }
    catch(Exception e)
        {   session.setAttribute("formLockout", "off");
            response.sendRedirect("admin_login.jsp");
        }
    }}catch(Exception e)
        {   session = request.getSession();
            session.setAttribute("username", "xxxxdefaultxxxx");
            session.setAttribute("sessionID", "xxxxdefaultxxxx");
                
            response.sendRedirect("../index.jsp");
            
        } %>
</html>
